#pragma once
#include "Agent.h"
#include "../anim/Animation.h"
#include "Ball.h"
#include "../particles/Emitter.h"
#include "../SGD Wrappers/SGD_Listener.h"

class CPlayer :
	public CAgent
{
public:
	CPlayer();
	~CPlayer();
	virtual void	Update(float elapsedTime) override;
	virtual void	Render(void)   override;

	virtual void Input(float speed);
	virtual void Sprint();
	virtual void Tackle();

	virtual void Throw(SGD::Vector throwVec);
	void StartCharge();
	bool GetCarrying() const { return m_bCarrying; }
	//False = BLUE_TEAM & True = RED_TEAM
	bool GetTeam() const { return m_bTeam; }
	virtual void HandleEvent(const SGD::Event* pEvent) override;
	virtual void HandleCollision(const Entity* pOther) override;
	void KeepInWorld();

	// Accessors
	bool GetHeading() { return m_bIsHeadingRight; }
	int	GetType() const override { return ENT_PLAYER; }
	
	virtual unsigned int GetControllernumber() const{ return m_iconnum; }
	CBall* GetBall()const{ return m_pBall; }
	float GetCharge()const{ return m_fAbilityCharge; }
	CEmitter* GetEmitter()const{ return m_pEmitter; }
	CPlayer* GetTeamMate()const{ return m_pTeamMate; }
	SGD::Rectangle GetAbilityRect()const{ return m_sgdAbilityRect; }							//For the ability meter HUD
	float GetCooldown()const{ return m_fCooldown; }
	float GetAbilityDelay()const{ return m_fAbilityDelay; }
	bool GetCDFlag()const{ return m_bOnCD; }
	int GetKnockBack()const{ return m_nKnockBack; }
	bool GetThrownAbility() const{ return m_bThrowAbility; }
	int GetPowerLevel() const{ return m_nPowerLevel; }
	SGD::Point GetHomePos() const { return m_ptHomePos; }
	bool GetThrowGuy() { return m_bThrowTheGuy; }
	int GetPowerLevel() { return m_nPowerLevel; }
	SGD::Vector GetThrownGuy(){	return m_vThrownGuy;}
	CPlayer* GetCarryDude() { return m_pCarryDude; }
	bool GetStun(){ return m_bPlayerStun; }
	float GetStunTimer(){ return m_fStunTimer; }
	bool GetBeingCarried(){ return m_bBeingCarried; }
	bool GetAmIInAMiniGame() { return m_bAmIInAMiniGame; }


	// Mutators
	virtual void SetControllernumber(unsigned int c){ m_iconnum = c; }
	void SetHomePos(SGD::Point homePos){ m_ptHomePos = homePos; }
	void SetTeam(bool t)			{ m_bTeam = t; }
	void SetCharge(float charge){ m_fAbilityCharge = charge; }
	void SetBall(CBall* b){ m_pBall = b; }
	void SetCarrying(bool carrying){ m_bCarrying = carrying; }
	void SetEmitter(CEmitter* e) { m_pEmitter = e; }
	
	void SetAbilityRect(SGD::Rectangle prmRect){ m_sgdAbilityRect = prmRect; }	//For the ability meter HUD
	void SetTeamMate(CPlayer* teammate) { m_pTeamMate = teammate; }
	void SetCooldown(float prmCooldown){ m_fCooldown = prmCooldown; }
	void SetAbilityDelay(float prmAbilityDelay){ m_fAbilityDelay = prmAbilityDelay; }
	void SetCDFlag(bool prmCDState) { m_bOnCD = prmCDState; }
	void SetKnockBack(int k){ m_nKnockBack = k; }
	void SetStealChance(int s){ m_nStealChance = s; }
	void SetThrownAbility(bool t) { m_bThrowAbility = t; }
	void SetThrownGuy(SGD::Vector v){ m_vThrownGuy = v; }
	void SetThrowGuy(bool b) {m_bThrowTheGuy = b; }
	void SetCarryDude(CPlayer* p) { m_pCarryDude = p; }
	void SetStun(bool b){ m_bPlayerStun = b; }
	void SetStunTimer(float s){ m_fStunTimer = s; }
	void SetBeingCarried(bool b){ m_bBeingCarried = b; }
	void SetAmIInAMiniGame(bool b){ m_bAmIInAMiniGame = b; }



protected:
	//False = BLUE_TEAM & True = RED_TEAM
	bool m_bTeam;
	bool m_bCarrying;
	bool m_bIsHeadingRight = true;

	float m_fAbilityCharge;
	int m_nStealChance = 15;

	//doms bombers throw power used to stun
	int m_nPowerLevel = 0;
	bool m_bPlayerStun = false;
	float m_fStunTimer = 0.0f;

	//charging stuff
	// X is 2 Y is 3
	int m_nButton = 0;
	float m_fCharging;
	// elapsedtime
	float m_fChargeTimer;

	unsigned char m_cPUpFlag;
	unsigned int m_iconnum;
	CBall* m_pBall = nullptr;
	bool m_bSprinting = false;
	bool m_bDash = false;
	float m_fDashTimer = 0.0f;

	CEmitter* m_pEmitter;
	CEmitter* m_pHitPar;
	float hitTimer;
	CPlayer* m_pTeamMate;
	CPlayer* m_pCarryDude = nullptr;
	int m_nKnockBack = 10;
	float m_fThrowCharge = 0.0f;
	
	SGD::Rectangle m_sgdAbilityRect;												//For the ability meter HUD
	float m_fCooldown;																//Cooldown timer
	float m_fAbilityDelay;															//Delay for spamming abilities
	bool m_bOnCD;																	//Check if were on cooldown or not.
	bool m_bAmIInAMiniGame = false;
	SGD::Point m_ptHomePos;

	bool m_bTakeDownRush = false;
	SGD::Vector m_vRushVel;
	float m_vRushTimer = 5;
	bool m_bThrowAbility = false;
	bool m_bThrowTheGuy = false;
	bool m_bBeingCarried = false;
	SGD::Vector m_vThrownGuy;
};

